fix(basichost): sort confirmed addrs#3526
Merged
Merged
Conversation
lidel
force-pushed
the
fix/autonatv2-sorted-confirmed-addrs
branch
from
July 15, 2026 21:10
45f2acf to
42aa212
Compare
lidel
commented
Jul 21, 2026
sukunrt
force-pushed
the
fix/autonatv2-sorted-confirmed-addrs
branch
from
July 22, 2026 15:21
42aa212 to
8f56b13
Compare
probeManager.AppendConfirmedAddrs emits primary addrs followed by secondary addrs. Each half is sorted, but the concatenation is not: a webrtc-direct secondary sorts before its quic-v1 primary on the same UDP socket. Both consumers in addrsManager require input sorted by Multiaddr.Compare: getConfirmedAddrs feeds the buckets to removeNotInSource, and Addrs() subtracts the unreachable bucket via removeInSource. Unsorted input makes removeNotInSource silently drop confirmed addrs, so ConfirmedAddrs() under-reports secondary transports even though the tracker confirmed them, defeating the reachability inheritance added in #3435. removeInSource fails the other way and retains confirmed-unreachable addrs in Addrs(). Sort the buckets in addrsManager.getConfirmedAddrs, next to the helpers that require the invariant, rather than in the tracker. Assisted-By: Claude Fable 5
sukunrt
force-pushed
the
fix/autonatv2-sorted-confirmed-addrs
branch
from
July 22, 2026 15:39
8f56b13 to
7f0d9b8
Compare
sukunrt
approved these changes
Jul 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
AutoNAT v2 keeps a list of the node's addresses that are confirmed reachable from the internet. The list is built in two parts: primary transports (tcp, quic-v1) first, then secondary ones (webrtc-direct, websocket, webtransport). Each part is sorted, but the combined list is not.
The consumer of that list,
removeNotInSource, assumes fully sorted input and silently drops entries when it is not. webrtc-direct is the common victim: on a shared UDP port its address sorts before quic-v1, so it lands out of order and gets dropped.ConfirmedAddrs()then says the node is not reachable over webrtc-direct even though AutoNAT just confirmed it was, undoing the inheritance from #3435. Kubo announces confirmed addresses to HTTP routers, so browsers never saw the webrtc-direct address (ipfs/kubo#11369) 🙈Fix